package com.learn.thymeleaf3.config;

/**
 * Created with Intellij IDEA.
 *
 * @Author: Gabriel
 * @Date: 2018-12-07
 * @Description:
 */
import org.thymeleaf.TemplateEngine;

import javax.servlet.ServletContext;

/**
 * Store and retrieves Thymeleaf TemplateEngine into the application servlet context.
 */

public class TemplateEngineUtil {

	private static final String TEMPLATE_ENGINE_ATTR = "com.e-learn.thymeleaf3.TemplateEngineInstance";

	public static void storeTemplateEngine(ServletContext context, TemplateEngine engine) {
		context.setAttribute(TEMPLATE_ENGINE_ATTR, engine);
	}

	public static TemplateEngine getTemplateEngine(ServletContext context) {
		return (TemplateEngine) context.getAttribute(TEMPLATE_ENGINE_ATTR);
	}

}